/**
 * XUCBrowserUserAgent.java
 * 
 * Copyright (c) 2004-2020 UC Mobile Ltd.
 * F/4,Building B,Guangzhou Xinxigang,No.16 Keyun Rd,Guangzhou,China
 * All right reserved.
 * 
 * Created on 2012-10-25
 */
package com.uc.browser.useragent;

/**
 * <b>XUCBrowserUserAgent简介:</b>
 * <p>UserAgent的扩展类，提供设备更加丰富的信息</p>
 *
 * <b>功能描述:</b>
 * <p>1. 提供设备的分辨率信息，包括像素分辨率，逻辑分辨率，屏幕旋转特性</p>
 * <p>2. 提供更丰富的浏览器功能特性，例如浏览模式，夜间模式等</p>
 * <p>3. 可动态扩展，提供比User-Agent更加丰富的信息来满足不同场景下的用户体验</p>
 *
 * @author raorq
 * @version 1.0
 */
public class XUCBrowserUserAgent extends UserAgent {
    
    private String xUCBrowserUserAgent          = null;
    private String pixel                        = null;
    private String density                      = null;
    private String proxyMode                    = null;
    private String browsingView                 = null;
    private String nightMode                    = null;
    private String noImageMode                  = null;
    private String screenRotation               = null;
    private String netType                      = null;
    private String btype                        = null;
    
    /**
     * <p>获取HTTP Header X-UCBrowser-UA数据</p>
     *
     * @return HTTP Header X-UCBrowser-UA
     */
    public String getxUCBrowserUserAgent() {
        return xUCBrowserUserAgent;
    }
    
    public void setxUCBrowserUserAgent(String xUCBrowserUserAgent) {
        this.xUCBrowserUserAgent = xUCBrowserUserAgent;
    }

    /**
     * <p>获取手持设备像素分辨率，例如：320*240</p>
     *
     * @return 设备像素分辨率
     */
    public String getPixel() {
        return pixel;
    }
    
    public void setPixel(String pixel) {
        this.pixel = pixel;
    }
    
    /**
     * <p>获取手持设备逻辑分辨率，例如：320*240， 此值只在iPhone，Android等智能设备上生效</p>
     *
     * @return 设备逻辑分辨率
     */
    public String getDensity() {
        return density;
    }
    
    public void setDensity(String density) {
        this.density = density;
    }
    
    /**
     * <p>获取浏览器访问模式</p>
     *
     * @return 浏览器访问模式
     */
    public String getProxyMode() {
        return proxyMode;
    }
    
    public void setProxyMode(String proxyMode) {
        this.proxyMode = proxyMode;
    }
    
    /**
     * <p>获取浏览器浏览模式</p>
     *
     * @return 浏览器浏览模式
     */
    public String getBrowsingView() {
        return browsingView;
    }
    
    public void setBrowsingView(String browsingView) {
        this.browsingView = browsingView;
    }
    
    /**
     * <p>获取浏览器夜间模式</p>
     *
     * @return 浏览器夜间模式
     */
    public String getNightMode() {
        return nightMode;
    }
    
    public void setNightMode(String nightMode) {
        this.nightMode = nightMode;
    }
    
    /**
     * <p>获取浏览器无图模式</p>
     *
     * @return 浏览器无图模式
     */
    public String getNoImageMode() {
        return noImageMode;
    }
    
    public void setNoImageMode(String noImageMode) {
        this.noImageMode = noImageMode;
    }
    
    /**
     * <p>获取浏览器的屏幕旋转模式</p>
     *
     * @return 浏览器的屏幕旋转模式
     */
    public String getScreenRotation() {
        return screenRotation;
    }
    
    public void setScreenRotation(String screenRotation) {
        this.screenRotation = screenRotation;
    }
    
    /**
     * <p>当前请求是否为无图模式</p>
     *
     * @return 是否为无图模式
     */
    public boolean isNoImageMode(){
        return noImageMode != null && noImageMode.equals(GlobalConstant.FUNCTION_OPEN);
    }
    
    /**
     * <p>当前请求模式是否为中转模式</p>
     *
     * @return 否为中转模式
     */
    public boolean isProxyMode(){
        return proxyMode != null && proxyMode.equals(GlobalConstant.FUNCTION_OPEN);
    }
    
    /**
     * <p>是否为夜间模式</p>
     *
     * @return 是否为夜间模式
     */
    public boolean isNightMode(){
        return nightMode != null && nightMode.equals(GlobalConstant.FUNCTION_OPEN);
    }
    
    /**
     * <p>浏览模式是否为适应屏幕</p>
     *
     * @return 是否为适应屏幕
     */
    public boolean browingViewIsAdaptScreen(){
        return browsingView != null && browsingView.equals(GlobalConstant.BROWSING_VIEW_ADATER_SCREEN);
    }
    
    /**
     * <p>浏览模式是否为缩放模式</p>
     *
     * @return 是否为缩放模式
     */
    public boolean browingViewIsZoom(){
        return  browsingView!= null && browsingView.equals(GlobalConstant.BROWSING_VIEW_ZOOM);
    }
    
    /**
     * <p>屏幕旋转是否跟随系统</p>
     *
     * @return 屏幕旋转是否跟随系统
     */
    public boolean screenRotationFollowSystem(){
        return screenRotation != null && screenRotation.equals(GlobalConstant.SCREEN_ROTATION_FOLLOW_SYSTEM);
    }
    
    /**
     * <p>屏幕旋转是否锁定竖屏</p>
     *
     * @return 屏幕旋转是否锁定竖屏
     */
    public boolean screenRotationLockVertical (){
        return screenRotation != null && screenRotation.equals(GlobalConstant.SCREEN_ROTATION_LOCK_VERTICAL);
    }
    
    /**
     * <p>屏幕旋转是否锁定横屏</p>
     *
     * @return 屏幕旋转是否锁定横屏
     */
    public boolean screenRotationLockHorizontal(){
        return screenRotation != null && screenRotation.equals(GlobalConstant.SCREEN_ROTATION_LOCK_HARIZONTAL);
    }
    
    /**
     * <p>网络类型</p>
     * 
     * @return 网络类型
     */
    public String getNetType() {
		return netType;
	}

	public void setNetType(String netType) {
		this.netType = netType;
	}

	/**
	 * <p>渠道类型</p>
	 * 
	 * @return 渠道类型
	 */
	public String getBtype() {
		return btype;
	}

	public void setBtype(String btype) {
		this.btype = btype;
	}

    public String toString(){
        String text= super.toString();
        StringBuilder sb = new StringBuilder();
        sb.append(text);
        sb.append("isProxyMode:                     ").append(isProxyMode()).append("\r\n");
        sb.append("isNightMode:                     ").append(isNightMode()).append("\r\n");
        sb.append("isNoImageMode:                   ").append(isNoImageMode()).append("\r\n");
        sb.append("browingViewIsAdaptScreen:        ").append(browingViewIsAdaptScreen()).append("\r\n");
        sb.append("browingViewIsZoom:               ").append(browingViewIsZoom()).append("\r\n");
        sb.append("screenRotationFollowSystem:      ").append(screenRotationFollowSystem()).append("\r\n");
        sb.append("screenRotationLockVertical:      ").append(screenRotationLockVertical()).append("\r\n");
        sb.append("screenRotationLockHorizontal:    ").append(screenRotationLockHorizontal()).append("\r\n");
        sb.append("Pixel:                           ").append(getPixel()).append("\r\n");
        sb.append("Density:                         ").append(getDensity()).append("\r\n");
        sb.append("NetType:                         ").append(getNetType()).append("\r\n");
        sb.append("Btype:                           ").append(getBtype()).append("\r\n");
        return sb.toString();
    }
     
}
